arcade-panel: start on hinge, better panel layout
[clinton/3d-models.git] / ble arcade controller / arcade-box.scad
CommitLineData
ee49ff3d
CE
1// arcade controller thing
2// Copyright (c) 2017 Clinton Ebadi <clinton@unknownlamer.org>
3// GPLv3 or (at your option) any later version
4// .. insert license text here ...
5
6use <obiscad/bcube.scad>
c3a57278 7use <obiscad/attach.scad>
7db674d2
CE
8use <joints.scad>
9
10
c3a57278
CE
11
12// PREVIEW
7db674d2
CE
13preview();
14module preview () {
c3a57278
CE
15 rotate ([-10, 0, 0]) translate ([0, 0, box_h+20]) panel ();
16 case ();
17}
18
19
20// CONFIGURATION
21
22panel_w = 250;
23panel_h = 120;
24
25box_h = 80; // fixme: box_d.
26box_wall = 2;
27base_h = 5; //fixme: thickness?
28
29// bcube parameters, clean up
30cr = box_wall*2;
31cres = 0;
ee49ff3d 32
7db674d2 33$button_d = 30;
c3a57278
CE
34js_width = 85;
35js_height = 40;
36
7db674d2
CE
37hinge_joint_width = 4;
38hinge_joint_thickness = 5;
39hinge_base_height = 10;
40
c3a57278 41// PANEL COMPONENTS
ee49ff3d
CE
42
43module button (bezel = $button_d+4) {
44 circle (d=$button_d);
45 %circle(d=bezel);
46}
47
ee49ff3d
CE
48
49module joystick () {
50 bolt_d = 8;
51 center_hole_d = 24;
52
c3a57278 53 for (x = [-js_width/2, js_width/2], y = [-js_height/2, js_height/2]) {
ee49ff3d
CE
54 translate ([x, y, 0]) circle (d=bolt_d); // need slot instead
55 }
c3a57278
CE
56 circle (d=center_hole_d);
57
58 %square ([js_width, js_height], center=true); // not right...
ee49ff3d
CE
59}
60
ee49ff3d 61
c3a57278 62// CASE
ee49ff3d 63
c3a57278
CE
64module case_base (h=base_h) {
65 bcube([panel_w, panel_h, h], cr, cres);
ee49ff3d
CE
66}
67
c3a57278 68module case_walls () {
ee49ff3d 69 difference() {
ee49ff3d 70 bcube([panel_w, panel_h, box_h-base_h], cr, cres);
7db674d2 71 bcube([panel_w-box_wall, panel_h-box_wall, box_h+1], cr, cres);
ee49ff3d 72 }
7db674d2
CE
73 %connector (case_connector_wall (x=10));
74 attach (case_connector_wall (x=10), hinge_connector_back ()) hinge_female ();
ee49ff3d
CE
75}
76
c3a57278
CE
77module case () {
78 case_base ();
7db674d2
CE
79 translate ([0, 0, box_h/2]) case_walls ();
80}
81
82
83// todo:
84// specify which wall (rear, front, left, right).
85// offset from center of wall, as vector
86// optional: inside/outside
87function case_connector_wall (x=0, y=0, z=0) = [ [panel_w/2-x, panel_h/2-y, (box_h-base_h)/2-z], [0,-1, 0], 0 ];
88
89// HINGE
90
91function hinge_connector_back (th=hinge_joint_thickness*2, h=hinge_base_height) = [ [0, th/2, h/2], [0,1, 0], 0 ];
92
93module hinge_female () {
94 w = hinge_joint_width * 2;
95 th = hinge_joint_thickness * 2;
96 jt = hinge_joint_thickness;
97 jw = hinge_joint_width;
98 h = hinge_base_height;
99
100 %connector (hinge_connector_back ());
101
102 difference () {
103 cube ([w, th, h], center=true);
104 joint_male_negative(male_joint_width=jw, male_joint_thickness=jt, forward_rom=90, backward_rom=90, male_joint_height=10);
105 }
ee49ff3d
CE
106}
107
108
c3a57278 109// PANEL
ee49ff3d
CE
110
111module panel () {
112 difference () {
c3a57278
CE
113 case_base ();
114 linear_extrude (base_h*2,center=true) panel_layout ();
ee49ff3d
CE
115 }
116}
117
c3a57278
CE
118module panel_attach (position, angle=0) {
119 x = position[0];
120 y = position[1];
7db674d2 121 c1 = [ [x, y, base_h/2], [0,0,1], angle ];
c3a57278 122 a1 = [ [0,0, 0], [0,0,0], 0 ];
7db674d2 123// %connector (c1); // fixme: don't use 2d for layout
c3a57278
CE
124 attach (c1, a1) children ();
125}
ee49ff3d 126
c3a57278 127// panel layout inspired by the Neo Geo layout
ee49ff3d 128module panel_layout () {
c3a57278
CE
129 translate ([-panel_w/2 + 40, 0, 0]) {
130 panel_attach ([0, 0], 90) joystick ();
131
132 // p1, coin (floating off in the distance...)
7db674d2
CE
133 translate ([160, 0, 0]) {
134 $button_d=16;
c3a57278 135 for (x = [0, $button_d+10]) {
7db674d2 136 panel_attach ([x, 42]) button ();
c3a57278
CE
137 }
138 }
ee49ff3d 139
c3a57278 140 // a, b, c, d
7db674d2
CE
141 translate ([60, -20, 0]) {
142 panel_attach ([0, 0]) button ();
c3a57278 143 for (i = [ 1 : 3 ]) {
7db674d2 144 panel_attach ([i*($button_d+10)-10, $button_d]) button ();
c3a57278 145 }
ee49ff3d
CE
146 }
147 }
148}